package com.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
@Component
public class MyMpHander implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", () -> LocalDateTime.now(), LocalDateTime.class); // 起始版本 3.3.3(推荐)
//        Object password = getFieldValByName("password", metaObject);
//        if(null == password){
//            //字段为空，可以进行填充
//            setFieldValByName("password", "123456", metaObject);
//        }
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
